package cn.chenwx.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface UserMapper {
    /**
     * 获得密码
     * @param username 用户名
     */
    @Select("select password from user where username=#{username}")
    String getPassword(String username);

    /**
     * 获得角色权限
     * @param username 用户名
     * @return user/admin
     */
    @Select("select role from user where username=#{username}")
    String getRole(@Param("username") String username);

    /**
     * 修改密码
     */
    void updatePassword(@Param("username") String username, @Param("newPassword") String newPassword);

    /**
     * 获得存在的用户
     */
    List<String> getUser();

    /**
     * 封号
     */
    void banUser(String username);

    /**
     * 检查用户状态
     */
    @Select("select ban from user where username=#{username}")
    int checkUserBanStatus(@Param("username") String username);

    /**
     * 获得用户角色默认的权限
     */
//    @Select("select permission from user where username=#{username}")
//    String getRolePermission(String username);

    /**
     * 获得用户的权限
     */
    @Select("select permission from user where username=#{username}")
    String getPermission(String username);

}
